<?php
/*
 * 服务器状态监控
 */
header('Content-type:text/html;charset=utf-8');
include '../Core/Common.php';
//check server status
$server_ip_list = array(
	'yunduan11.com',
	'43.226.46.173',
	'apis.hs-pya.com',
	'tool.chinaz.com',
	'jiadian.jd.com',
	'43.226.46.173',
	'taobao.com'
);
?>
<!doctype html>
<html lang="zh_CN">
<head>
	<meta charset="UTF-8">
	<title>服务器状态监控</title>
	<style>
	* {
		margin: 0px;
		padding: 0px;
	}
	body {
		font-family: "Microsoft yahei",Arial;
		font-size:14px;
	}
	header {
		height: 40px;
		background-color: #2e2e2e;
		width: 100%;
		line-height: 35px;
	}
	header > h3 {
		color: #fff;
		margin-left: 20px;
	}
	footer {
		text-align: center;
	}
	a {
		color: #424242;
		text-decoration: none;
	}
	.wrap {
		height: auto;
		zoom:1;
		overflow: auto;
		max-width: 500px;
		width: 100%;
		margin: 50px auto;
	}
	.table {
		border-collapse: collapse;
		border: 1px solid #eee;
		width: 100%;
	}
	tr,td{
		color: #424242;
		border-collapse: collapse;
		border: 1px solid #F0F0F0;
		height: 30px;
		text-align: center;
	}
	tr:nth-child(2n+1) {
		background-color: #F7F8FC;
	}
	tr:hover {
		background-color: #F7F8FC;
	}
	.online,.offline {
		height: 20px;
		background-color: #2ECC71;
		width: 40px;
		margin: 0px auto;
		-webkit-border-radius: 5px;
		-moz-border-radius: 5px;
		border-radius: 5px;
		color: #fff;
	}
	.offline {
		width: 50px;
		background-color: #E74C3C;
	}
	</style>
</head>
<body>
	<header>
		<h3>服务器状态监控</h3>
	</header>
	<div class="wrap">
		<table class="table">
			<tbody>
				<tr><td>序号</td><td>服务器域名</td><td>服务器IP</td><td>服务器地域</td><td>状态</td></tr>
				<?php
					$i = 0;
					foreach ($server_ip_list as $key => $val) {
						$checkServerSatatus = checkServerSatatus($server_ip_list[$key]);
						$i++;
						if ($checkServerSatatus['code']) {
							echo "<tr>
							<td>{$i}</td>
							<td>{$server_ip_list[$key]}</td>
							<td>{$checkServerSatatus['IP']}</td>
							<td>{$checkServerSatatus['Country']}</td>
							<td><div class=\"online\">在线</div>[".$checkServerSatatus['Ping']."]</td></tr>";
						} else {
							echo "<tr>
							<td>{$i}</td>
							<td>{$server_ip_list[$key]}</td>
							<td>服务器异常</td>
							<td>服务器异常</td>
							<td><div class=\"offline\">不在线</div></td>
							</tr>";
							$subject = "服务器 {$server_ip_list[$key]} 异常提醒！";
							$body = "您好,旗下服务器{$server_ip_list[$key]} 出现异常，此邮件根据你设置的监控频率发送，当服务器恢复正常邮件自动停止发送！";
							//send_mail('2109877665@qq.com', $subjec, $body);
						}
					}

				 ?>
			</tbody>
		</table>
	</div>
	<footer>
		<p>Power By <a href="/" target="_blank">零度</a>-Auto By <a href="/"  target="_blank" rel="nofollow">cxsir</a></p>
	</footer>
</body>
</html>
